package jmysql;

import java.io.IOException;
import java.net.MalformedURLException;

import com.itextpdf.text.BadElementException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Element;
import com.itextpdf.text.Image;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;

public class CReportes {

	public CReportes(){
		
	}
	
	public PdfPTable titulo(String titulo,String absoluteDiskPath) throws BadElementException, MalformedURLException, IOException{
		
		Image imghead = Image.getInstance(absoluteDiskPath);
		imghead.scaleToFit(100, 100);
		
		float[] colsWidth = {1f, 2f}; // Code 1
		PdfPTable table0 = new PdfPTable(colsWidth);
		table0.setWidthPercentage(100);
		
		PdfPCell cell = new PdfPCell (imghead);
		Phrase p=new Phrase(titulo);
		p.getFont().setSize(24);
		
		PdfPCell cell2 = new PdfPCell (p);
		cell.setHorizontalAlignment(Element.ALIGN_CENTER);
		cell.setBorder(0);
		cell2.setBorder(0);
		table0.addCell(cell);
		table0.addCell(cell2);
		
		return table0;
		
	}
	public PdfPCell Subtitulo(String sub){
		Phrase px=new Phrase(""+sub+"\n ");
		px.getFont().setSize(19);
		PdfPCell cellx=new PdfPCell(px);
		cellx.setColspan(2);
		cellx.setHorizontalAlignment(Element.ALIGN_CENTER);
		cellx.setVerticalAlignment(Element.ALIGN_CENTER);
		return cellx;
	}
	
	public Phrase EspacioBlanco(){
		return new Phrase(" ");
	}
	
	
	public PdfPCell X_Centrado_Color(String valor){
		Phrase px=new Phrase("  "+valor+"\n ");
		px.getFont().setSize(9);
		px.getFont().setColor(BaseColor.RED);
			
		PdfPCell cellx=new PdfPCell(px);
		cellx.setHorizontalAlignment(Element.ALIGN_CENTER);
		return cellx;
	}
	
	public PdfPCell X_Personalizado(String valor, BaseColor color){
		Phrase px=new Phrase("  "+valor+"\n ");
		px.getFont().setSize(9);
		px.getFont().setColor(color);
			
		PdfPCell cellx=new PdfPCell(px);
		cellx.setHorizontalAlignment(Element.ALIGN_CENTER);
		return cellx;
	}
	
	
	public PdfPCell CeldaX(String valor){
		Phrase px=new Phrase("  "+valor+"\n ");
		px.getFont().setSize(9);
		PdfPCell cellx=new PdfPCell(px);
		cellx.setHorizontalAlignment(Element.ALIGN_LEFT);
		return cellx;
	}
	
	public PdfPCell CeldaY(String valor){
		Phrase px=new Phrase("  "+valor+"\n ");
		px.getFont().setSize(9);
		PdfPCell cellx=new PdfPCell(px);
		cellx.setHorizontalAlignment(Element.ALIGN_LEFT);
		return cellx;
	}
	
	
	public float[] dos_columnas(){
		float[] colsWidth = {1f, 2f};
		return colsWidth;
	}
	
	public float[] dos_columnasver1(){
		float[] colsWidth = {2f, 1f};
		return colsWidth;
	}
	
}
